package it.polimi.jita.cp.sketchbook;

import java.util.Set;

import org.apache.commons.math3.distribution.RealDistribution;

public class GraphState {
	private String id;
	private Set<VirtualMachineData> onVms;
	private Set<VirtualMachineData> offVms;
	private Double value;
	private final RealDistribution onToOffCdf;
	private final RealDistribution offToOnCdf;

	protected GraphState(Set<VirtualMachineData> onVms,
			Set<VirtualMachineData> offVms, Double value,
			RealDistribution onToOffCdf, RealDistribution offToOnCdf) {
		super();
		this.onVms = onVms;
		this.offVms = offVms;
		this.value = value;
		this.onToOffCdf = onToOffCdf;
		this.offToOnCdf = offToOnCdf;
		id = generateGraphStateId(onVms);
	}

	private String generateGraphStateId(Set<VirtualMachineData> onVms) {
		StringBuilder sb = new StringBuilder();
		for (VirtualMachineData virtualMachineData : onVms) {
			sb.append(virtualMachineData.getId());
			sb.append("-");

		}
		return null;
	}

	protected String getId() {
		return id;
	}

	protected Set<VirtualMachineData> getOnVms() {
		return onVms;
	}

	protected Set<VirtualMachineData> getOffVms() {
		return offVms;
	}

	protected Double getValue() {
		return value;
	}

	protected void setValue(Double value) {
		this.value = value;
	}

	protected double getArrowValueFor(GraphState state, Long instant) {
		Set<VirtualMachineData> newOnVms = state.getOnVms();
		double arrowValue = 0d;
		for (VirtualMachineData virtualMachineData : newOnVms) {
			if (newOnVms.contains(virtualMachineData)) {
				long vmCounter = virtualMachineData.getCounter();

				break;
			}
			// arrowValue *= virtualMachineData.
		}

		return arrowValue;
	}

}
